package cn.loan.controller.api;

import cn.loan.tools.GsonTool;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.net.*;
import java.sql.Date;
import java.util.Map;

/**
 * @Author: 毛苏宇
 * @Description: You can do it!
 * @Date: Create in 16:32 2019/3/24
 */
@RestController
@CrossOrigin
@RequestMapping("/api/vip")
public class TestController {

    /**
     * 查看服务器
     * @param session
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/look")
    public String look(HttpSession session) throws Exception{
        return "此设备与服务器的会话ID:"
                +session.getId()
                +"<br/>时间:"+new Date(System.currentTimeMillis());
    }

    @GetMapping(value = "/os")
    @ResponseBody
    public String getOsInfo(){
        Map<String,String> map = System.getenv();
        return GsonTool.mapToJson(map);
    }

}
